<?php

namespace App\Http\Controllers\Admin;

use App\Services\UserService;
use Illuminate\Http\Request;

class UserController extends AdminBaseController
{
    /**
     * @var UserService
     */
    private $userService;

    /**
     * UserController constructor.
     * @param UserService $userService
     */
    public function __construct(UserService $userService)
    {
        $this->userService = $userService;
    }

    /**
     * 获取用户列表
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function list(Request $request): \Illuminate\Http\JsonResponse
    {
        $params = $request->all();
        $data = $this->userService->list($params);
        return $this->success($data);
    }

    /**
     * 获取用户详情
     * @param int $id
     * @return \Illuminate\Http\JsonResponse
     */
    public function view(int $id): \Illuminate\Http\JsonResponse
    {
        $data = $this->userService->view($id);
        return $this->success($data);
    }

    /**
     * 用户下拉选择
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function select(Request $request): \Illuminate\Http\JsonResponse
    {
        $params = $request->all();
        $data = $this->userService->select($params);
        return $this->success($data);
    }
}